#pragma once

#include <iostream>
#include <string>
#include <memory>
#include <cstring>
 #include <sys/epoll.h>
 #include "log.hpp"
namespace base
{
    static const int default_epoll_fd = -1;
    static const int default_create_epoll_flag = 0;
    static const int epoll_cloexec_flag = EPOLL_CLOEXEC;
    class Channel
    {
    private:
        int _epfd; // epoll句柄
    public:
        using ptr = std::unique_ptr<Channel>;
        Channel(int epfd = default_epoll_fd) :_epfd(epfd)
        {
            _epfd = ::epoll_create1(default_create_epoll_flag); 
            if(_epfd < 0)
            {
                LOG(LogLevel::ERROR) << "创建epoll模型实例失败,原因: "<<strerror(errno);
                abort();
            }
            LOG(LogLevel::INFO) << "创建epoll模型实例成功,fd: "<<_epfd;
        }
        ~Channel()
        {}
        
    };
}